local mingchao = fk.CreateSkill{
    name = "wk_heg__mingchao",
}

Fk:loadTranslationTable{
  ["wk_heg__mingchao"] = "鸣潮",
  [":wk_heg__mingchao"] = "出牌阶段，你可选择一项：1.展示X张此回合未展示的手牌，然后使用其中一张牌；" ..
  "2.弃置X张此回合未展示的牌，然后摸一张牌。你不能以此法连续选择相同项。（X为此回合发动此技能次数+1）",

  ["@@wk_heg__mingchao_shown-inhand-turn"] = "鸣潮",
  ["wk_heg__mingchao_show"] = "展示牌，然后使用其中一张牌",
  ["wk_heg__mingchao_discard"] = "弃置牌，然后摸一张牌",
  ["#wk_heg__mingchao"] = "鸣潮：你可以展示或弃置此回合未展示过的牌，然后执行对应效果",
  ["#wk_heg__mingchao-use"] = "鸣潮：你可以使用其中一张牌",

  ["$wk_heg__mingchao1"] = "宦海沉浮，生死难料！",
  ["$wk_heg__mingchao2"] = "跨海南征，波涛起浮。",
}

mingchao:addEffect("active",{
  anim_type = "special",
  prompt = "#wk_heg__mingchao",
  interaction = function(self, player)
  local names = {}
  local all_choices = {"wk_heg__mingchao_show", "wk_heg__mingchao_discard"}
  for _, name in ipairs(all_choices) do
    if name == "wk_heg__mingchao_show" and player:getMark("wk_heg__mingchao_used-turn") ~= 1  then
      table.insertIfNeed(names, name)
    end
    if name == "wk_heg__mingchao_discard" and player:getMark("wk_heg__mingchao_used-turn") ~= 2  then
      table.insertIfNeed(names, name)
    end
  end
  if #names == 0 then return end
    return UI.ComboBox {choices = names, all_choices = all_choices }
  end,
  can_use = Util.TrueFunc,
  card_filter = function(self, player, to_select, selected)
    if not ((Fk:currentRoom():getCardArea(to_select) == Player.Hand or Fk:currentRoom():getCardArea(to_select) == Player.Equip)
      and Fk:getCardById(to_select):getMark("@@wk_heg__mingchao_shown-inhand-turn") == 0) then return false end
    if self.interaction.data:startsWith("wk_heg__mingchao_discard") then
      return not player:prohibitDiscard(to_select)
    else
      return Fk:currentRoom():getCardArea(to_select) == Player.Hand
    end
  end,
  target_filter = Util.FalseFunc,
  target_num = 0,
  card_num = function(self)
    return Self:usedSkillTimes(mingchao.name) + 1
  end,
  on_use = function(self, room, effect)
    if not self.interaction.data then return end
    local player = effect.from
    local card = effect.cards
    if self.interaction.data:startsWith("wk_heg__mingchao_show") then
      player:showCards(card)
      for _, id in ipairs(card) do
        room:setCardMark(Fk:getCardById(id), "@@wk_heg__mingchao_shown-inhand-turn", 1)
      end
      local to = player
      if not to:isKongcheng() then
        local use = room:askToUseRealCard(player,{
          pattern = card,
          skill_name = mingchao.name,
          prompt = "#wk_heg__mingchao-use",
          extra_data = {bypass_times = true, extraUse = true},
          skip = true,
        })
        if use then
          room:useCard(use)
        end
      end
      room:setPlayerMark(player, "wk_heg__mingchao_used-turn", 1)
    else
      room:throwCard(card, mingchao.name, player, player)
      player:drawCards(1, mingchao.name)
      room:setPlayerMark(player, "wk_heg__mingchao_used-turn", 2)
    end
  end,
})

return mingchao